#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Author  : hu_cl
# @Contact : 760730895@qq.com 
# @Date    : 2020/12/2 11:43
# @File    : Upgrade_api_test.py
import requests

api_url = ["http://192.168.2.5:8088/IPC_API/lpc_enumdevice/",
           "http://192.168.2.5:8088/IPC_API/lpc_cmd_query/",
           "http://192.168.2.5:8088/IPC_API/lpc_cmd_clean/",
           "http://192.168.2.5:8088/IPC_API/lpc_cmd_upgrade/",
           "http://192.168.2.5:8088/IPC_API/lpc_cmd_upgradeprog/"]

header_list = {
    "Content-Type": "application/json",
    "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36",
}

if __name__ == '__main__':
    while True:
        for i, element in enumerate(api_url):
            print(i + 1, element)
        i = int(input("请选择需要测试API(输入为0时，退出测试): "))
        if i == 0:
            break
        test_url = api_url[i - 1]
        print('当前测试的API地址为：{}'.format(test_url))
        # 参数{"DevProvider": "HIKVISION", "DevType": "DVR", "DevModel": "*"}
        content = input("请输入需要传输的参数 格式为{'':'','':'',}")
        print("输入的参数为{}".format(content))
        try:
            result = requests.post(url=test_url, headers=header_list, data=content)
        except Exception as e:
            print(f"查询失败，错误信息为{e}")
        else:
            print("查询的结果为 {}".format(result.text))







